package demo11;


/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86183
 */
public class Test {

    public static Animal func2(){
        Dog dog= new Dog( "柴六斤",5);
        return dog;
    }
    public static void func(Animal animal){
        animal.eat();
    }

    public static void main(String[] args) {
      /*  Animal animal= new Dog( "柴六斤",5);
        //向下转型
        Dog dog = (Dog)animal;
        dog.running();//dog类中方法*/
        Animal animal= new Cat( "富贵",3);
        if(animal instanceof Cat) {
            Cat cat = (Cat) animal;
            cat.jumping();
        }
    }
    public static void main3(String[] args) {
        //方法传参
        Dog dog= new Dog( "柴六斤",5);
        func(dog);
        Cat cat= new Cat( "富贵",3);
        func(cat);
    }
    public static void main2(String[] args) {
        Animal animal= new Dog( "柴六斤",5);
        animal.eat();//Animal类中方法
        System.out.println("==========");
        Animal animal2= new Cat( "富贵",3);
        animal2.eat();
    }
    /*animal.running();//Dog类中的方法 error*/
    public static void main1(String[] args) {
          /*//直接赋值
        Animal animal= new Dog( "柴六斤",5);
*/
         /* //方法传参
        Dog dog= new Dog( "柴六斤",5);
        func(dog);*/
       /* //返回值
        Animal animal = func2();*/

    }


}
